*******************************
* IRCA and Redistricting
* Navid Sabet and Noam Yuchtman
* Figure 8: IRCA and Hispanic-majority districts
*******************************

	//Load data
	use irca_gerrymander.dta, clear
	
	//Controls
	global controls  c.pop1990#i.p102 c.inc_pc1990#i.p102  c.age_share1990#i.p102 c.unemployment_1990#i.p102 c.educ1990##i.p102 c.births_1990#i.p102 c.black_share1990#i.p102 c.white_share1990#i.p102
	
	//Fully interacted controls
	global controls_full  c.pop1990##i.p102##i.legal_control_kaplan1991 c.inc_pc1990##i.p102##i.legal_control_kaplan1991  c.age_share1990##i.p102##i.legal_control_kaplan1991 c.unemployment_1990##i.p102##i.legal_control_kaplan1991 c.educ1990##i.p102##i.legal_control_kaplan1991 c.births_1990##i.p102##i.legal_control_kaplan1991 c.black_share1990##i.p102##i.legal_control_kaplan1991 c.white_share1990##i.p102##i.legal_control_kaplan1991
	
	//VRA controls
	global vra_control i.vra_covered##i.p102
	global vra_full i.vra_covered##i.p102##i.legal_control_kaplan1991 
	
	//Extra controls
	global extras c.povrate_1990#i.p102 c.hsd_share1990#i.p102 c.spr010_1990#i.p102 c.spr030_1990#i.p102 c.housing_value_1990#i.p102 c.crime_1990#1.p102
	
	 //1980 Controls
	global controls1980 c.population_bea1980#i.p102 c.income_pc1980#i.p102  c.age_share1980#i.p102 c.edu6351980#i.p102 c.births_1980#i.p102 c.black_share1980#i.p102 c.white_share1980#i.p102
	
	
	//Controls pre post 1980 redistricting (placebo model controls)
	global controls97 c.pop1990#i.p97 c.inc_pc1990#i.p97  c.age_share1990#i.p97 c.unemployment_1990#i.p97 c.educ1990##i.p97 c.births_1990#i.p97 c.black_share1990#i.p97 c.white_share1990#i.p97
	
	//VRA controls: pre post 1980 redistricting (placebo model controls)
	global vra_control97 i.vra_covered##i.p97 
	
	//Fixed effects
	global fe id congress#StateFIPS c.hisp_share1980#i.congress i.unassigned_county#i.year 
	
	//Clustering
	global cluster id

	//Generate filler variables.
	gen x_base = legal_control_kaplan1991
	gen x_none = legal_control_kaplan1991
	gen x_extra = legal_control_kaplan1991
	gen x_1980 = legal_control_kaplan1991
	gen x_full = legal_control_kaplan1991
	gen x_arp = arp_nocommission
	gen x_hisp = legal_control_kaplan1991
	gen x_treated = legal_control_kaplan1991
	gen x_single = legal_control_kaplan1991
	gen x_mm = legal_control_kaplan1991
	gen x_placebo = legal_control_kaplan1981
	
****************
* Robustness Results
****************
//Hispanic Majority
eststo clear
	
	//Baseline
	reghdfe hisp_majority_county $controls $vra_control c.irca_std##1.p102##ib2.x_base [weight = cuts] , a($fe) cluster($cluster)
	estadd scalar clusters = e(N_clust)
	eststo base
	sum hisp_majority_county if e(sample) & p102==0
	
	 //No controls
	reghdfe hisp_majority_county c.irca_std##i.p102##ib2.x_none [weight = cuts] , a($fe) cluster($cluster)
	estadd scalar clusters = e(N_clust)
	eststo none
	
	//Extra controls
	reghdfe hisp_majority_county $controls $vra_control $extras c.irca_std##i.p102##ib2.x_extra [weight = cuts] , a($fe) cluster($cluster)
	estadd scalar clusters = e(N_clust)
	eststo extra
	
	//1980 Controls
	reghdfe hisp_majority_county $controls1980 $vra_control c.irca_std##i.p102##ib2.x_1980 [weight = cuts] , a($fe) cluster($cluster)	
	estadd scalar clusters = e(N_clust)
	eststo 	eighty
	
	//Interacted Observables (Fully Saturated)
	reghdfe hisp_majority_county $controls_full $vra_full c.irca_std##i.p102##ib2.x_full [weight = cuts] , a($fe) cluster($cluster)
	estadd scalar clusters = e(N_clust)
	eststo full
	
	//Alternative Definition of Legal Control
	reghdfe hisp_majority_county $controls $vra_control c.irca_std##i.p102##ib2.x_arp [weight = cuts] , a($fe) cluster($cluster)
	estadd scalar clusters = e(N_clust)
	eststo arp
	
	//Using Hispanic share instead of imputing
	reghdfe hisp_majority_county $controls $vra_control c.irca_pc1990_hisp_std##i.p102##ib2.x_hisp [weight = cuts] , a($fe) cluster($cluster)
	estadd scalar clusters = e(N_clust)
	eststo hisp
	
	//Drop imputed counties
	reghdfe hisp_majority_county $controls $vra_control c.irca_std##i.p102##ib2.x_treated if unassigned_county == 0 [weight = cuts], a($fe) cluster($cluster)
	estadd scalar clusters = e(N_clust)
	eststo no_impute
	
	 //Only single district counties
	reghdfe hisp_majority_county $controls $vra_control c.irca_std##1.p102##ib2.x_single [weight = cuts] if cuts==1, a($fe) cluster($cluster)
	estadd scalar clusters = e(N_clust)
	eststo single_dist
	
	//Drop minority-majority counties
	reghdfe hisp_majority_county $controls $vra_control c.irca_std##1.p102##ib2.x_mm [weight = cuts] if StateFIPS!=35, a($fe) cluster($cluster)
	estadd scalar clusters = e(N_clust)
	eststo mm
	
	//Falsification
	reghdfe hisp_majority_county $controls97 $vra_control97 c.irca_std##i.p97##ib2.x_placebo , a($fe) cluster($cluster)
	estadd scalar clusters = e(N_clust)
	eststo placebo
		

//Plot		
coefplot base none extra eighty full arp hisp no_impute single_dist mm placebo, ///
		|| , keep(1.p102#1.x_base#c.irca_std ///
			1.p102#1.x_none#c.irca_std ///
			1.p102#1.x_extra#c.irca_std ///
			1.p102#1.x_1980#c.irca_std ///
			1.p102#1.x_full#c.irca_std ///
			1.p102#1.x_arp#c.irca_std ///
			1.p102#1.x_hisp#c.irca_pc1990_hisp_std ///
			1.p102#1.x_treated#c.irca_std ///
			1.p102#1.x_single#c.irca_std ///
			1.p102#1.x_mm#c.irca_std ///
			1.p97#1.x_placebo#c.irca_std) ///
			coeflabels(1.p102#1.x_base#c.irca_std = "Baseline (1)" ///
						1.p102#1.x_none#c.irca_std = "No Controls (2)" ///
						1.p102#1.x_extra#c.irca_std = "Extra Controls (3)" ///
						1.p102#1.x_1980#c.irca_std = "1980 Controls (4)" /// 
						1.p102#1.x_full#c.irca_std = "Fully Interacted (5)" /// 
						1.p102#1.x_arp#c.irca_std = "Legal Control (6)" /// 
						1.p102#1.x_hisp#c.irca_pc1990_hisp_std = "Hispanic Imputation (7)" /// 
						1.p102#1.x_treated#c.irca_std = "No Imputation (8)" /// 
						1.p102#1.x_single#c.irca_std = "Single Districts (9)" ///
						1.p102#1.x_mm#c.irca_std = "Drop NM (10)" ///
						1.p97#1.x_placebo#c.irca_std = "1980 Placebo (11)") ///
						headings(1.p102#1.x_base#c.irca_std = `"{bf:Empirical Specifications}"'        ///
								1.p102#1.x_treated#c.irca_std = `"{bf:Sample Restrictions}"'                     ///
							   1.p97#1.x_placebo#c.irca_std = `""{bf:Placebo}" ""' ) ///
							   legend(off) title(, size(normal)) ///
							   xline(0, ) ciopts(recast(rcap) lcolor(gs8)) msymbol(smcircle) grid(none) offset(1/128)
	
	
	graph export fig8.pdf, replace
	graph save fig8.gph, replace
			
